package controllers;

import models.GuideInfo;
import play.data.Form;
import play.mvc.*;
import play.data.validation.Constraints.*;

import views.html.*;


public class Guide extends Controller {
final static Form<GuideInfo> guideInfoForm = form(GuideInfo.class);
	
	
	public static Result index() {
		return ok(guideIntro.render(form(GuideInfo.class)));
	}
	

	public static Result test() {
		return ok("test is working");
	}
	 public static Result add() {
		 Form<GuideInfo> giForm = form(GuideInfo.class).bindFromRequest();
		 giForm.get().setUser(Application.getLocalUser(session()));
        if(giForm.hasErrors()) {
            return badRequest(guideIntro.render(giForm));
        }
        giForm.get().save();
        //flash("success", "Computer " + giForm.get().name + " has been created");
        return ok("Saved");
	 }

	
}